<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#div{
				
			}
		</style>
	</head>
	<body>
		<div id="div">
			<div id="">
				列表
			</div>
		</div>
		<div id="div1">
			<div id="">
				数据库
			</div>
		</div>
		
		<script src="bck/static/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			function btn(obj)
			{
				alert($(obj).attr("code"));
				$.ajax({
					type:"post",
					url:"email.php",
					dataType:"json",
					data:{
						code:$(obj).attr("code")
					},
					success:function(msg){
						console.log(msg);
						for(var a in msg)
						{
							var str="";
							for(var a1 in msg[a])
							{
								if(a1!=='uid')
								{
									str+=`<div style="display: inline-block;" id="">`+msg[a][a1]+`</div>&nbsp;`;
								}
							}	
							$("#div1").append(`<div id="">`+str+`<button uid="`+msg[a]['uid']+`" onclick="btn1(this)">发送</button></div>`);
							
						}
					}
				})
			}
			
			function btn1(obj)
			{
				
				if($(obj).attr("gk")=="yes")
				{
					$.ajax({
						type:"post",
						url:"PHPMailer1.php",
						dataType:"json",
						data:{
							title:$(obj).parent().children().eq(1).text(),
							name:$(obj).parent().children().eq(0).text(),
							content:$(obj).parent().children().eq(2).text()
						},
						success:function(msg){
							$(obj).attr("gk","no");
							console.log(msg);
							for(var a in msg)
							{
								$("#div").append(`<div id="">`+msg[a]+`<button code="`+(parseInt(a) +1)+`" onclick="btn(this)" gk="yes">导入</button></div>`);
							}
						}
					})
				}
				//alert($(obj).parent().children().eq(0).text());
				
				
			}
			
			
			$(document).ready(function(){
				$.ajax({
					type:"post",
					url:"email1.php",
					dataType:"json",
					success:function(msg){
						console.log(msg);
						for(var a in msg)
						{
							$("#div").append(`<div id="">`+msg[a]+`<button code="`+(parseInt(a) +1)+`" onclick="btn(this)">导入</button></div>`);
						}
					}
				})
			});
		</script>
	</body>
</html>
